import type { Event } from './model';

import type { ID, PageQuery, PageResult } from '#/api/common';

import { requestClient } from '#/api/request';

enum Api {
  eventAdd = '/crawler/targetEvent/add',
  eventDeleteTargetEvent = '/crawler/targetEvent/deleteTargetEvent',
  eventDeleteById = '/crawler/targetEvent/deleteTargetEvent',
  eventUpdate = '/crawler/targetEvent/update',
  eventQueryBYPage = '/crawler/targetEvent/queryByPage',
  eventGetAllTargetEvent = '/crawler/targetEvent/getAllTargetEvent',
  eventGetById = '/crawler/targetEvent/getById',
}

/**
 * 新增系统配置
 * @param data 参数
 */
export function eventAdd(data: Partial<Event>) {
  return requestClient.postWithMsg<void>(Api.eventAdd, data);
}

/**
 * 删除配置
 * @param eventId id
 */
export function eventDeleteById(eventId: ID) {
  return requestClient.deleteWithMsg<void>(`${Api.eventDeleteById}?id=${eventId}`);
}

/**
 * 更新事件目标
 * @param data 参数
 */
export function eventUpdate(data: Partial<Event>) {
  return requestClient.putWithMsg<void>(Api.eventUpdate, data);
}

/**
 * 事件分页列表
 * @param params 请求参数
 * @returns 列表
 */
export function eventList(params?: PageQuery) {
  return requestClient.get<PageResult<Event>>(Api.eventQueryBYPage, { params });
}

/**
 * 事件分页列表
 * @param eventId 请求参数
 * @returns 列表
 */
export function eventGetById(eventId: ID) {
  return requestClient.get<PageResult<Event>>(`${Api.eventGetById}?id=${eventId}`);
}



